home *** CD-ROM | disk | FTP | other *** search
/ The Datafile PD-CD 1 Issue 2 / PDCD-1 - Issue 02.iso / _utilities / utilities / 001 / meschach / !Meschach / c / zmemory < prev    next >
Text File  |  1994-04-05  |  15KB  |  714 lines

  1.  
  2. /**************************************************************************
  3. **
  4. ** Copyright (C) 1993 David E. Steward & Zbigniew Leyk, all rights reserved.
  5. **
  6. **                 Meschach Library
  7. ** 
  8. ** This Meschach Library is provided "as is" without any express 
  9. ** or implied warranty of any kind with respect to this software. 
  10. ** In particular the authors shall not be liable for any direct, 
  11. ** indirect, special, incidental or consequential damages arising 
  12. ** in any way from use of the software.
  13. ** 
  14. ** Everyone is granted permission to copy, modify and redistribute this
  15. ** Meschach Library, provided:
  16. **  1.  All copies contain this copyright notice.
  17. **  2.  All modified copies shall carry a notice stating who
  18. **      made the last modification and the date of such modification.
  19. **  3.  No charge is made for this software or works derived from it.  
  20. **      This clause shall not be construed as constraining other software
  21. **      distributed on the same medium as this software, nor is a
  22. **      distribution fee considered a charge.
  23. **
  24. ***************************************************************************/
  25.  
  26.  
  27. /* Memory allocation and de-allocation for complex matrices and vectors */
  28.  
  29. #include    <stdio.h>
  30. #include    "zmatrix.h"
  31.  
  32. static    char    rcsid[] = "$Id: zmemory.c,v 1.2 1994/04/05 02:13:14 des Exp $";
  33.  
  34.  
  35.  
  36. /* zv_zero -- zeros all entries of a complex vector
  37.    -- uses __zzero__() */
  38. ZVEC    *zv_zero(x)
  39. ZVEC    *x;
  40. {
  41.    if ( ! x )
  42.      error(E_NULL,"zv_zero");
  43.    __zzero__(x->ve,x->dim);
  44.    
  45.    return x;
  46. }
  47.  
  48. /* zm_zero -- zeros all entries of a complex matrix
  49.    -- uses __zzero__() */
  50. ZMAT    *zm_zero(A)
  51. ZMAT    *A;
  52. {
  53.    int        i;
  54.    
  55.    if ( ! A )
  56.      error(E_NULL,"zm_zero");
  57.    for ( i = 0; i < A->m; i++ )
  58.      __zzero__(A->me[i],A->n);
  59.    
  60.    return A;
  61. }
  62.  
  63. /* zm_get -- gets an mxn complex matrix (in ZMAT form) */
  64. ZMAT    *zm_get(m,n)
  65. int    m,n;
  66. {
  67.    ZMAT    *matrix;
  68.    u_int    i;
  69.    
  70.    if (m < 0 || n < 0)
  71.      error(E_NEG,"zm_get");
  72.  
  73.    if ((matrix=NEW(ZMAT)) == (ZMAT *)NULL )
  74.      error(E_MEM,"zm_get");
  75.    else if (mem_info_is_on()) {
  76.       mem_bytes(TYPE_ZMAT,0,sizeof(ZMAT));
  77.       mem_numvar(TYPE_ZMAT,1);
  78.    }
  79.    
  80.    matrix->m = m;        matrix->n = matrix->max_n = n;
  81.    matrix->max_m = m;    matrix->max_size = m*n;
  82. #ifndef SEGMENTED
  83.    if ((matrix->base = NEW_A(m*n,complex)) == (complex *)NULL )
  84.    {
  85.       free(matrix);
  86.       error(E_MEM,"zm_get");
  87.    }
  88.    else if (mem_info_is_on()) {
  89.       mem_bytes(TYPE_ZMAT,0,m*n*sizeof(complex));
  90.    }
  91. #else
  92.    matrix->base = (complex *)NULL;
  93. #endif
  94.    if ((matrix->me = (complex **)calloc(m,sizeof(complex *))) == 
  95.        (complex **)NULL )
  96.    {    free(matrix->base);    free(matrix);
  97.     error(E_MEM,"zm_get");
  98.      }
  99.    else if (mem_info_is_on()) {
  100.       mem_bytes(TYPE_ZMAT,0,m*sizeof(complex *));
  101.    }
  102. #ifndef SEGMENTED
  103.    /* set up pointers */
  104.    for ( i=0; i<m; i++ )
  105.      matrix->me[i] = &(matrix->base[i*n]);
  106. #else
  107.    for ( i = 0; i < m; i++ )
  108.      if ( (matrix->me[i]=NEW_A(n,complex)) == (complex *)NULL )
  109.        error(E_MEM,"zm_get");
  110.      else if (mem_info_is_on()) {
  111.     mem_bytes(TYPE_ZMAT,0,n*sizeof(complex));
  112.      }
  113. #endif
  114.    
  115.    return (matrix);
  116. }
  117.  
  118.  
  119. /* zv_get -- gets a ZVEC of dimension 'dim'
  120.    -- Note: initialized to zero */
  121. ZVEC    *zv_get(size)
  122. int    size;
  123. {
  124.    ZVEC    *vector;
  125.  
  126.    if (size < 0)
  127.      error(E_NEG,"zv_get");
  128.  
  129.    if ((vector=NEW(ZVEC)) == (ZVEC *)NULL )
  130.      error(E_MEM,"zv_get");
  131.    else if (mem_info_is_on()) {
  132.       mem_bytes(TYPE_ZVEC,0,sizeof(ZVEC));
  133.       mem_numvar(TYPE_ZVEC,1);
  134.    }
  135.    vector->dim = vector->max_dim = size;
  136.    if ((vector->ve=NEW_A(size,complex)) == (complex *)NULL )
  137.    {
  138.       free(vector);
  139.       error(E_MEM,"zv_get");
  140.    }
  141.    else if (mem_info_is_on()) {
  142.       mem_bytes(TYPE_ZVEC,0,size*sizeof(complex));
  143.    }
  144.    return (vector);
  145. }
  146.  
  147. /* zm_free -- returns ZMAT & asoociated memory back to memory heap */
  148. int    zm_free(mat)
  149. ZMAT    *mat;
  150. {
  151. #ifdef SEGMENTED
  152.    int    i;
  153. #endif
  154.    
  155.    if ( mat==(ZMAT *)NULL || (int)(mat->m) < 0 ||
  156.        (int)(mat->n) < 0 )
  157.      /* don't trust it */
  158.      return (-1);
  159.    
  160. #ifndef SEGMENTED
  161.    if ( mat->base != (complex *)NULL ) {
  162.       if (mem_info_is_on()) {
  163.      mem_bytes(TYPE_ZMAT,mat->max_m*mat->max_n*sizeof(complex),0);
  164.       }       
  165.       free((char *)(mat->base));
  166.    }
  167. #else
  168.    for ( i = 0; i < mat->max_m; i++ )
  169.      if ( mat->me[i] != (complex *)NULL ) {
  170.     if (mem_info_is_on()) {
  171.        mem_bytes(TYPE_ZMAT,mat->max_n*sizeof(complex),0);
  172.     }
  173.     free((char *)(mat->me[i]));
  174.      }
  175. #endif
  176.    if ( mat->me != (complex **)NULL ) {
  177.       if (mem_info_is_on()) {
  178.      mem_bytes(TYPE_ZMAT,mat->max_m*sizeof(complex *),0);
  179.       }       
  180.       free((char *)(mat->me));
  181.    }
  182.    
  183.    if (mem_info_is_on()) {
  184.       mem_bytes(TYPE_ZMAT,sizeof(ZMAT),0);
  185.       mem_numvar(TYPE_ZMAT,-1);
  186.    }
  187.    free((char *)mat);
  188.    
  189.    return (0);
  190. }
  191.  
  192.  
  193. /* zv_free -- returns ZVEC & asoociated memory back to memory heap */
  194. int    zv_free(vec)
  195. ZVEC    *vec;
  196. {
  197.    if ( vec==(ZVEC *)NULL || (int)(vec->dim) < 0 )
  198.      /* don't trust it */
  199.      return (-1);
  200.    
  201.    if ( vec->ve == (complex *)NULL ) {
  202.       if (mem_info_is_on()) {
  203.      mem_bytes(TYPE_ZVEC,sizeof(ZVEC),0);
  204.      mem_numvar(TYPE_ZVEC,-1);
  205.       }
  206.       free((char *)vec);
  207.    }
  208.    else
  209.    {
  210.       if (mem_info_is_on()) {
  211.      mem_bytes(TYPE_ZVEC,vec->max_dim*sizeof(complex)+
  212.               sizeof(ZVEC),0);
  213.      mem_numvar(TYPE_ZVEC,-1);
  214.       }
  215.       
  216.       free((char *)vec->ve);
  217.       free((char *)vec);
  218.    }
  219.    
  220.    return (0);
  221. }
  222.  
  223.  
  224. /* zm_resize -- returns the matrix A of size new_m x new_n; A is zeroed
  225.    -- if A == NULL on entry then the effect is equivalent to m_get() */
  226. ZMAT    *zm_resize(A,new_m,new_n)
  227. ZMAT    *A;
  228. int    new_m, new_n;
  229. {
  230.    u_int    i, new_max_m, new_max_n, new_size, old_m, old_n;
  231.    
  232.    if (new_m < 0 || new_n < 0)
  233.      error(E_NEG,"zm_resize");
  234.  
  235.    if ( ! A )
  236.      return zm_get(new_m,new_n);
  237.    
  238.    if (new_m == A->m && new_n == A->n)
  239.      return A;
  240.  
  241.    old_m = A->m;    old_n = A->n;
  242.    if ( new_m > A->max_m )
  243.    {    /* re-allocate A->me */
  244.       if (mem_info_is_on()) {
  245.      mem_bytes(TYPE_ZMAT,A->max_m*sizeof(complex *),
  246.               new_m*sizeof(complex *));
  247.       }
  248.  
  249.       A->me = RENEW(A->me,new_m,complex *);
  250.       if ( ! A->me )
  251.     error(E_MEM,"zm_resize");
  252.    }
  253.    new_max_m = max(new_m,A->max_m);
  254.    new_max_n = max(new_n,A->max_n);
  255.    
  256. #ifndef SEGMENTED
  257.    new_size = new_max_m*new_max_n;
  258.    if ( new_size > A->max_size )
  259.    {    /* re-allocate A->base */
  260.       if (mem_info_is_on()) {
  261.      mem_bytes(TYPE_ZMAT,A->max_m*A->max_n*sizeof(complex),
  262.         new_size*sizeof(complex));      
  263.       }
  264.  
  265.       A->base = RENEW(A->base,new_size,complex);
  266.       if ( ! A->base )
  267.     error(E_MEM,"zm_resize");
  268.       A->max_size = new_size;
  269.    }
  270.    
  271.    /* now set up A->me[i] */
  272.    for ( i = 0; i < new_m; i++ )
  273.      A->me[i] = &(A->base[i*new_n]);
  274.    
  275.    /* now shift data in matrix */
  276.    if ( old_n > new_n )
  277.    {
  278.       for ( i = 1; i < min(old_m,new_m); i++ )
  279.     MEM_COPY((char *)&(A->base[i*old_n]),
  280.          (char *)&(A->base[i*new_n]),
  281.          sizeof(complex)*new_n);
  282.    }
  283.    else if ( old_n < new_n )
  284.    {
  285.       for ( i = min(old_m,new_m)-1; i > 0; i-- )
  286.       {   /* copy & then zero extra space */
  287.      MEM_COPY((char *)&(A->base[i*old_n]),
  288.           (char *)&(A->base[i*new_n]),
  289.           sizeof(complex)*old_n);
  290.      __zzero__(&(A->base[i*new_n+old_n]),(new_n-old_n));
  291.       }
  292.       __zzero__(&(A->base[old_n]),(new_n-old_n));
  293.       A->max_n = new_n;
  294.    }
  295.    /* zero out the new rows.. */
  296.    for ( i = old_m; i < new_m; i++ )
  297.      __zzero__(&(A->base[i*new_n]),new_n);
  298. #else
  299.    if ( A->max_n < new_n )
  300.    {
  301.       complex    *tmp;
  302.       
  303.       for ( i = 0; i < A->max_m; i++ )
  304.       {
  305.      if (mem_info_is_on()) {
  306.         mem_bytes(TYPE_ZMAT,A->max_n*sizeof(complex),
  307.              new_max_n*sizeof(complex));
  308.      }
  309.  
  310.      if ( (tmp = RENEW(A->me[i],new_max_n,complex)) == NULL )
  311.        error(E_MEM,"zm_resize");
  312.      else {
  313.         A->me[i] = tmp;
  314.      }
  315.       }
  316.       for ( i = A->max_m; i < new_max_m; i++ )
  317.       {
  318.      if ( (tmp = NEW_A(new_max_n,complex)) == NULL )
  319.        error(E_MEM,"zm_resize");
  320.      else {
  321.         A->me[i] = tmp;
  322.         if (mem_info_is_on()) {
  323.            mem_bytes(TYPE_ZMAT,0,new_max_n*sizeof(complex));
  324.         }
  325.      }
  326.       }
  327.    }
  328.    else if ( A->max_m < new_m )
  329.    {
  330.       for ( i = A->max_m; i < new_m; i++ )
  331.     if ( (A->me[i] = NEW_A(new_max_n,complex)) == NULL )
  332.       error(E_MEM,"zm_resize");
  333.     else if (mem_info_is_on()) {
  334.        mem_bytes(TYPE_ZMAT,0,new_max*sizeof(complex));
  335.     }
  336.       
  337.    }
  338.    
  339.    if ( old_n < new_n )
  340.    {
  341.       for ( i = 0; i < old_m; i++ )
  342.     __zzero__(&(A->me[i][old_n]),new_n-old_n);
  343.    }
  344.    
  345.    /* zero out the new rows.. */
  346.    for ( i = old_m; i < new_m; i++ )
  347.      __zzero__(A->me[i],new_n);
  348. #endif
  349.    
  350.    A->max_m = new_max_m;
  351.    A->max_n = new_max_n;
  352.    A->max_size = A->max_m*A->max_n;
  353.    A->m = new_m;    A->n = new_n;
  354.    
  355.    return A;
  356. }
  357.  
  358.  
  359. /* zv_resize -- returns the (complex) vector x with dim new_dim
  360.    -- x is set to the zero vector */
  361. ZVEC    *zv_resize(x,new_dim)
  362. ZVEC    *x;
  363. int    new_dim;
  364. {
  365.    if (new_dim < 0)
  366.      error(E_NEG,"zv_resize");
  367.  
  368.    if ( ! x )
  369.      return zv_get(new_dim);
  370.  
  371.    if (new_dim == x->dim)
  372.      return x;
  373.  
  374.    if ( x->max_dim == 0 )    /* assume that it's from sub_zvec */
  375.      return zv_get(new_dim);
  376.    
  377.    if ( new_dim > x->max_dim )
  378.    {
  379.       if (mem_info_is_on()) { 
  380.      mem_bytes(TYPE_ZVEC,x->max_dim*sizeof(complex),
  381.               new_dim*sizeof(complex));
  382.       }
  383.  
  384.       x->ve = RENEW(x->ve,new_dim,complex);
  385.       if ( ! x->ve )
  386.     error(E_MEM,"zv_resize");
  387.       x->max_dim = new_dim;
  388.    }
  389.    
  390.    if ( new_dim > x->dim )
  391.      __zzero__(&(x->ve[x->dim]),new_dim - x->dim);
  392.    x->dim = new_dim;
  393.    
  394.    return x;
  395. }
  396.  
  397.  
  398. /* varying arguments */
  399.  
  400. #ifdef ANSI_C
  401.  
  402. #include <stdarg.h>
  403.  
  404.  
  405. /* To allocate memory to many arguments. 
  406.    The function should be called:
  407.    zv_get_vars(dim,&x,&y,&z,...,NULL);
  408.    where 
  409.      int dim;
  410.      ZVEC *x, *y, *z,...;
  411.      The last argument should be NULL ! 
  412.      dim is the length of vectors x,y,z,...
  413.      returned value is equal to the number of allocated variables
  414.      Other gec_... functions are similar.
  415. */
  416.  
  417. int zv_get_vars(int dim,...) 
  418. {
  419.    va_list ap;
  420.    int i=0;
  421.    ZVEC **par;
  422.    
  423.    va_start(ap, dim);
  424.    while (par = va_arg(ap,ZVEC **)) {   /* NULL ends the list*/
  425.       *par = zv_get(dim);
  426.       i++;
  427.    } 
  428.  
  429.    va_end(ap);
  430.    return i;
  431. }
  432.  
  433.  
  434.  
  435. int zm_get_vars(int m,int n,...) 
  436. {
  437.    va_list ap;
  438.    int i=0;
  439.    ZMAT **par;
  440.    
  441.    va_start(ap, n);
  442.    while (par = va_arg(ap,ZMAT **)) {   /* NULL ends the list*/
  443.       *par = zm_get(m,n);
  444.       i++;
  445.    } 
  446.  
  447.    va_end(ap);
  448.    return i;
  449. }
  450.  
  451.  
  452.  
  453. /* To resize memory for many arguments. 
  454.    The function should be called:
  455.    v_resize_vars(new_dim,&x,&y,&z,...,NULL);
  456.    where 
  457.      int new_dim;
  458.      ZVEC *x, *y, *z,...;
  459.      The last argument should be NULL ! 
  460.      rdim is the resized length of vectors x,y,z,...
  461.      returned value is equal to the number of allocated variables.
  462.      If one of x,y,z,.. arguments is NULL then memory is allocated to this 
  463.      argument. 
  464.      Other *_resize_list() functions are similar.
  465. */
  466.  
  467. int zv_resize_vars(int new_dim,...)
  468. {
  469.    va_list ap;
  470.    int i=0;
  471.    ZVEC **par;
  472.    
  473.    va_start(ap, new_dim);
  474.    while (par = va_arg(ap,ZVEC **)) {   /* NULL ends the list*/
  475.       *par = zv_resize(*par,new_dim);
  476.       i++;
  477.    } 
  478.  
  479.    va_end(ap);
  480.    return i;
  481. }
  482.  
  483.  
  484.  
  485. int zm_resize_vars(int m,int n,...) 
  486. {
  487.    va_list ap;
  488.    int i=0;
  489.    ZMAT **par;
  490.    
  491.    va_start(ap, n);
  492.    while (par = va_arg(ap,ZMAT **)) {   /* NULL ends the list*/
  493.       *par = zm_resize(*par,m,n);
  494.       i++;
  495.    } 
  496.  
  497.    va_end(ap);
  498.    return i;
  499. }
  500.  
  501.  
  502. /* To deallocate memory for many arguments. 
  503.    The function should be called:
  504.    v_free_vars(&x,&y,&z,...,NULL);
  505.    where 
  506.      ZVEC *x, *y, *z,...;
  507.      The last argument should be NULL ! 
  508.      There must be at least one not NULL argument.
  509.      returned value is equal to the number of allocated variables.
  510.      Returned value of x,y,z,.. is VNULL.
  511.      Other *_free_list() functions are similar.
  512. */
  513.  
  514. int zv_free_vars(ZVEC **pv,...)
  515. {
  516.    va_list ap;
  517.    int i=1;
  518.    ZVEC **par;
  519.    
  520.    zv_free(*pv);
  521.    *pv = ZVNULL;
  522.    va_start(ap, pv);
  523.    while (par = va_arg(ap,ZVEC **)) {   /* NULL ends the list*/
  524.       zv_free(*par); 
  525.       *par = ZVNULL;
  526.       i++;
  527.    } 
  528.  
  529.    va_end(ap);
  530.    return i;
  531. }
  532.  
  533.  
  534.  
  535. int zm_free_vars(ZMAT **va,...)
  536. {
  537.    va_list ap;
  538.    int i=1;
  539.    ZMAT **par;
  540.    
  541.    zm_free(*va);
  542.    *va = ZMNULL;
  543.    va_start(ap, va);
  544.    while (par = va_arg(ap,ZMAT **)) {   /* NULL ends the list*/
  545.       zm_free(*par); 
  546.       *par = ZMNULL;
  547.       i++;
  548.    } 
  549.  
  550.    va_end(ap);
  551.    return i;
  552. }
  553.  
  554.  
  555.  
  556. #elif VARARGS
  557.  
  558. #include <varargs.h>
  559.  
  560. /* To allocate memory to many arguments. 
  561.    The function should be called:
  562.    v_get_vars(dim,&x,&y,&z,...,NULL);
  563.    where 
  564.      int dim;
  565.      ZVEC *x, *y, *z,...;
  566.      The last argument should be NULL ! 
  567.      dim is the length of vectors x,y,z,...
  568.      returned value is equal to the number of allocated variables
  569.      Other gec_... functions are similar.
  570. */
  571.  
  572. int zv_get_vars(va_alist) va_dcl
  573. {
  574.    va_list ap;
  575.    int dim,i=0;
  576.    ZVEC **par;
  577.    
  578.    va_start(ap);
  579.    dim = va_arg(ap,int);
  580.    while (par = va_arg(ap,ZVEC **)) {   /* NULL ends the list*/
  581.       *par = zv_get(dim);
  582.       i++;
  583.    } 
  584.  
  585.    va_end(ap);
  586.    return i;
  587. }
  588.  
  589.  
  590.  
  591. int zm_get_vars(va_alist) va_dcl
  592. {
  593.    va_list ap;
  594.    int i=0, n, m;
  595.    ZMAT **par;
  596.    
  597.    va_start(ap);
  598.    m = va_arg(ap,int);
  599.    n = va_arg(ap,int);
  600.    while (par = va_arg(ap,ZMAT **)) {   /* NULL ends the list*/
  601.       *par = zm_get(m,n);
  602.       i++;
  603.    } 
  604.  
  605.    va_end(ap);
  606.    return i;
  607. }
  608.  
  609.  
  610.  
  611. /* To resize memory for many arguments. 
  612.    The function should be called:
  613.    v_resize_vars(new_dim,&x,&y,&z,...,NULL);
  614.    where 
  615.      int new_dim;
  616.      ZVEC *x, *y, *z,...;
  617.      The last argument should be NULL ! 
  618.      rdim is the resized length of vectors x,y,z,...
  619.      returned value is equal to the number of allocated variables.
  620.      If one of x,y,z,.. arguments is NULL then memory is allocated to this 
  621.      argument. 
  622.      Other *_resize_list() functions are similar.
  623. */
  624.  
  625. int zv_resize_vars(va_alist) va_dcl
  626. {
  627.    va_list ap;
  628.    int i=0, new_dim;
  629.    ZVEC **par;
  630.    
  631.    va_start(ap);
  632.    new_dim = va_arg(ap,int);
  633.    while (par = va_arg(ap,ZVEC **)) {   /* NULL ends the list*/
  634.       *par = zv_resize(*par,new_dim);
  635.       i++;
  636.    } 
  637.  
  638.    va_end(ap);
  639.    return i;
  640. }
  641.  
  642.  
  643. int zm_resize_vars(va_alist) va_dcl
  644. {
  645.    va_list ap;
  646.    int i=0, m, n;
  647.    ZMAT **par;
  648.    
  649.    va_start(ap);
  650.    m = va_arg(ap,int);
  651.    n = va_arg(ap,int);
  652.    while (par = va_arg(ap,ZMAT **)) {   /* NULL ends the list*/
  653.       *par = zm_resize(*par,m,n);
  654.       i++;
  655.    } 
  656.  
  657.    va_end(ap);
  658.    return i;
  659. }
  660.  
  661.  
  662.  
  663. /* To deallocate memory for many arguments. 
  664.    The function should be called:
  665.    v_free_vars(&x,&y,&z,...,NULL);
  666.    where 
  667.      ZVEC *x, *y, *z,...;
  668.      The last argument should be NULL ! 
  669.      There must be at least one not NULL argument.
  670.      returned value is equal to the number of allocated variables.
  671.      Returned value of x,y,z,.. is VNULL.
  672.      Other *_free_list() functions are similar.
  673. */
  674.  
  675. int zv_free_vars(va_alist) va_dcl
  676. {
  677.    va_list ap;
  678.    int i=0;
  679.    ZVEC **par;
  680.    
  681.    va_start(ap);
  682.    while (par = va_arg(ap,ZVEC **)) {   /* NULL ends the list*/
  683.       zv_free(*par); 
  684.       *par = ZVNULL;
  685.       i++;
  686.    } 
  687.  
  688.    va_end(ap);
  689.    return i;
  690. }
  691.  
  692.  
  693.  
  694. int zm_free_vars(va_alist) va_dcl
  695. {
  696.    va_list ap;
  697.    int i=0;
  698.    ZMAT **par;
  699.    
  700.    va_start(ap);
  701.    while (par = va_arg(ap,ZMAT **)) {   /* NULL ends the list*/
  702.       zm_free(*par); 
  703.       *par = ZMNULL;
  704.       i++;
  705.    } 
  706.  
  707.    va_end(ap);
  708.    return i;
  709. }
  710.  
  711.  
  712. #endif
  713.  
  714.